GEN_SRC := gen-cpp/DB.cpp gen-cpp/cloud_constants.cpp gen-cpp/cloud_types.cpp
GEN_OBJ := $(patsubst %.cpp,%.o, $(GEN_SRC))

THRIFT_DIR := /home/rizhao/test/thrift
LIBEVENT_DIR := /home/rizhao/test/libevent
LEVELDB_DIR := /home/rizhao/test/leveldb-read-only

INC := -I. -I./gen-cpp -I$(THRIFT_DIR)/include/thrift -I$(LIBEVENT_DIR)/include -I$(LEVELDB_DIR)/include -I$(LEVELDB_DIR)/

CXXFLAGS := -Wall -g $(INC)

LDFLAGS := -L$(THRIFT_DIR)/lib -L$(LIBEVENT_DIR)/lib -L$(LEVELDB_DIR)
LIB :=-lthriftnb -lthrift -lleveldb -lsnappy -levent -lboost_program_options -lpthread -lrt

.PHONY: all clean

all: DB_server DB_client 

%.o: %.cpp
	$(CXX) -c $(CXXFLAGS) $< -o $@

DB_server: DB_server.o cloudbase.o $(GEN_OBJ)
	$(CXX) -o $@ $^ $(LDFLAGS) $(LIB)

DB_client: DB_client.o $(GEN_OBJ)
	$(CXX) -o $@ $^ $(LDFLAGS) $(LIB)

benchmark: benchmark.o
	$(CXX) -o $@ $^ $(LDFLAGS) $(LIB)

clean:
	$(RM) ./gen-cpp/*.o *.o DB_server DB_client
